

package com.hazelcast.collection;

import com.hazelcast.transaction.TransactionalQueue;

import javax.annotation.Nonnull;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.TimeUnit;

/**
 * Concurrent, blocking, distributed, observable queue.
 * <p>
 * The IQueue is not a partitioned data-structure. All the content of an
 * IQueue is stored in a single machine (and in the backup).
 * The IQueue will not scale by adding more members to the cluster.
 *
 * @param <E> queue item type
 * @see BaseQueue
 * @see java.util.Queue
 * @see BlockingQueue
 * @see TransactionalQueue
 */
public interface IQueue<E> extends BlockingQueue<E>, BaseQueue<E>, ICollection<E> {
    /*
     * Added poll(), poll(long timeout, TimeUnit unit) and take()
     * methods here to prevent wrong method return type issue when
     * compiled with java 8.
     *
     * For additional details see:
     *
     * http://mail.openjdk.java.net/pipermail/compiler-dev/2014-November/009139.html
     * https://bugs.openjdk.java.net/browse/JDK-8064803
     *
     */

    /**
     * {@inheritDoc}
     */
    @Override
    E poll();

    /**
     * {@inheritDoc}
     */
    @Override
    E poll(long timeout, @Nonnull TimeUnit unit) throws InterruptedException;

    /**
     * {@inheritDoc}
     */
    @Nonnull
    @Override
    E take() throws InterruptedException;

    /**
     * Returns LocalQueueStats for this queue.
     * LocalQueueStats is the statistics for the local portion of this
     * queue.
     *
     * @return this queue's local statistics.
     */
    LocalQueueStats getLocalQueueStats();
}
